package cc.rengu.redp.bizimpl.upmp.controller;


import cc.rengu.igas.bomp.facade.BompMchntInspectService;
import cc.rengu.redp.bizimpl.upmp.service.IInspectTaskDetailService;
import cc.rengu.redp.bizimpl.upmp.service.IUpmpBMchntBaseInfoService;
import cc.rengu.redp.bizimpl.upmp.service.IUpmpSysParamService;
import cc.rengu.redp.bizimpl.upmp.vo.UpmpUserInfoVO;
import cc.rengu.redp.bizimpl.utils.CommonUtils;
import cc.rengu.redp.common.controller.BaseController;
import cc.rengu.redp.common.domain.QueryRequest;
import cc.rengu.redp.common.exception.RedpException;
import io.swagger.annotations.Api;
import lombok.extern.slf4j.Slf4j;
import org.apache.dubbo.config.annotation.DubboReference;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import java.util.Map;

/**
 * @author 刘玉亮.LL
 */
@Slf4j
@Api(tags = "商户管理:商户巡检记录查询")
@RestController
@RequestMapping(value = "/admin/merParam/inspectTaskDetailQuery")
public class InspectTaskDetailQueryController extends BaseController {
    @Autowired
    private IInspectTaskDetailService inspectTaskDetailService;

    @DubboReference(version = "${dubbo.protocol.version}", check = false)
    private BompMchntInspectService mchntInspectService;

    @Autowired
    private IUpmpSysParamService upmpSysParamService;

    @Autowired
    private IUpmpBMchntBaseInfoService bMchntBaseInfoService;


//    @RequiresPermissions("inspectTaskDetailQuery:list")
    @GetMapping(value = "/list")
    public Map<String, Object> findByPage(HttpServletRequest request, QueryRequest queryRequest) throws RedpException {
        UpmpUserInfoVO user = CommonUtils.getCurrentUser(upmpSysParamService);
        return getDataTable(inspectTaskDetailService.findPageFromBomp(request, queryRequest, user, mchntInspectService, bMchntBaseInfoService.genMerOrder(user.getInstId())));
    }
}
